import asyncio
from longport.openapi import QuoteContext, SubType, Config
from strategy_engine import TradingEngine
async def main():
    # 替换为实际top10标的
    # symbols = ['AAPL.US', 'NVDA.US', 'MSFT.US', 'GOOG.US', 'META.US', 'TELA.US', 'AVGO.US', 'TSM.US']
    symbols = ['LLY.US',]

    # 初始化交易引擎
    engine = TradingEngine(symbols)

    # 连接行情API
    config = Config.from_env()
    quote_ctx = QuoteContext(config)

    # 行情回调处理
    quote_ctx.set_on_quote(engine.data_processor.on_market_data)

    # 订阅实时行情
    quote_ctx.subscribe(symbols, [SubType.Quote], True)

    # 启动交易引擎
    await engine.run()
    # await asyncio.Future()

if __name__ == "__main__":
    asyncio.run(main())